package com.ruoyi.studentCourse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.studentCourse.domain.StudentCourse;
import com.ruoyi.studentCourse.service.IStudentCourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生课表管理Controller
 * 
 * @author dlh
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/studentCourse/studentCourse")
public class StudentCourseController extends BaseController
{
    @Autowired
    private IStudentCourseService studentCourseService;

    /**
     * 查询学生课表管理列表
     */
    @PreAuthorize("@ss.hasPermi('studentCourse:studentCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentCourse studentCourse)
    {
        startPage();
        List<StudentCourse> list = studentCourseService.selectStudentCourseList(studentCourse);
        return getDataTable(list);
    }

    /**
     * 导出学生课表管理列表
     */
    @PreAuthorize("@ss.hasPermi('studentCourse:studentCourse:export')")
    @Log(title = "学生课表管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentCourse studentCourse)
    {
        List<StudentCourse> list = studentCourseService.selectStudentCourseList(studentCourse);
        ExcelUtil<StudentCourse> util = new ExcelUtil<StudentCourse>(StudentCourse.class);
        util.exportExcel(response, list, "学生课表管理数据");
    }

    /**
     * 获取学生课表管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('studentCourse:studentCourse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(studentCourseService.selectStudentCourseById(id));
    }

    /**
     * 新增学生课表管理
     */
    @PreAuthorize("@ss.hasPermi('studentCourse:studentCourse:add')")
    @Log(title = "学生课表管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentCourse studentCourse)
    {
        return toAjax(studentCourseService.insertStudentCourse(studentCourse));
    }

    /**
     * 修改学生课表管理
     */
    @PreAuthorize("@ss.hasPermi('studentCourse:studentCourse:edit')")
    @Log(title = "学生课表管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentCourse studentCourse)
    {
        return toAjax(studentCourseService.updateStudentCourse(studentCourse));
    }

    /**
     * 删除学生课表管理
     */
    @PreAuthorize("@ss.hasPermi('studentCourse:studentCourse:remove')")
    @Log(title = "学生课表管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(studentCourseService.deleteStudentCourseByIds(ids));
    }
}
